<!DOCTYPE html>
<html>
  <head>
  	<title>XunJie Tech  CAAS Softphone Demo</title>
  	<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/> 
  	<link href="css/style.css" rel="stylesheet" type="text/css" media="screen" />
  
  	<script type="text/javascript" src="js/CAASSoftphone.js"></script>
  	<script type="text/javascript">
 function plugin0()
{
    return document.getElementById('plugin0');
}
plugin = plugin0;
function addEvent(obj, name, func)
{
    if (obj.attachEvent) {
        obj.attachEvent("on"+name, func);
    } else {
        obj.addEventListener(name, func, false); 
    }
}

function InitSoftPhone() 
{
    // 设置外观样式
    plugin().BGroundColorValueR = 100;
    plugin().BGroundColorValueG = 162;
    plugin().BGroundColorValueB = 223;
    plugin().ButtonOffsetColor = 30;
    // 设置小休原因、是否需要申请及相关策略
    plugin().AuxworkReasons ="0,吃饭|1,会议|2,培训|3,系统故障|4,其他|5,休息|";
    plugin().AuxworkNeedsApply = false;
    plugin().AuxworkMaxLimit = 0;
    plugin().LanguageResourceFile = "XSPhoneResource_cn.xml";
    // 设置是否管理员(管理员小休无需申请，且具备监听、拦截、强插功能)
    plugin().IsManager = false;
    // 设置是否启动发送WebSerivce请求线程及接口
    plugin().EnableWebServiceRequest = false; //是否连接cm service
    plugin().WebServiceIPAddr = "129.1.202.3";//129.1.202.3
    plugin().WebServicePort = 8099;
    plugin().WebServiceMethodName = "service/servlet/procM";
    plugin().WebServiceApiAgentHandsUp = "";
    //发送坐席状态信息至CM SERVICE
    plugin().WebServiceApiAgentStatusChg = "exec=true&methodName=agentStatus&callBack=0&execType=0&methodType=set&AgentID=[AgentId]&AgentStat=[AgentStation]&AgentType=[AgentType]&IPAddr=[IPAddr]&Status=[AgentCallStatus]&CallID=[CallId]&OtherDN=[OtherDN]&CallInType=[CallInType]";
    //可咨询的组的信息
    plugin().WebServiceApiConsultGroup = "exec=true&methodName=agentStatus&callBack=0&execType=0&methodType=consultGroup&AgentID=[AgentId]";
    //plugin().WebServiceApiConsultGroup = "exec=true&methodName=agentStatus&callBack=0&execType=0&methodType=comcodeList&AgentID=[AgentId]";
    //可管理的组的信息
    plugin().WebServiceApiManagedGroup = "exec=true&methodName=agentStatus&callBack=0&execType=0&methodType=manageGroup&AgentID=[AgentId]";
    //plugin().WebServiceApiManagedGroup = "exec=true&methodName=agentStatus&callBack=0&execType=0&methodType=comcodeList&AgentID=[AgentId]";  
    //根据组号和projectID来获取组内坐席的信息
    plugin().WebServiceApiAgentInGroup = "exec=true&methodName=agentStatus&callBack=0&execType=0&methodType=comcodeAgent&Comcode=[Comcode]&ProjectID=[ProjectId]";  
    //获取互斥状态
    plugin().WebServiceApiMutexDetect = "exec=true&methodName=agentStatus&callBack=0&execType=0&methodType=mutexDetect&AgentID=[AgentId]";
    //空闲管理员IP地址
    plugin().WebServiceApiGetIdleMonitor = "exec=true&methodName=agentStatus&callBack=0&execType=0&methodType=getMonitorIp&AgentID=[AgentId]";
    //获取组内小休人数
    plugin().WebServiceApiGetAuxworkCount = "exec=true&methodName=agentStatus&callBack=0&execType=0&methodType=getNotReadyCount&AgentID=[AgentId]";
    //软电话心跳
   plugin().WebServiceApiSendHeartBeat = "exec=true&methodName=agentStatus&callBack=0&execType=0&AgentID=[AgentId]&methodType=beat";
    
    plugin().WebServiceApiReservation4 = "false";
    plugin().WebServiceApiReservation5 = "";


    // 设置话务及操作相关属性
    plugin().CTIServerIPAddr ="192.168.1.150:6003";   //129.1.202.1:42028,129.1.202.1:42028,
    plugin().ProxyServerIPAddr = "";
    plugin().RecServerIPAddr = "172.18.5.29";
    plugin().RecServerPort = "3001";
    plugin().EnableDebugConsole = true;
    plugin().EnableLog = true;
    plugin().LogPath = "c:\\Logs";
    //plugin().AgentId = "test10";
    //plugin().AgentPswd = "test1234";
    //plugin().AgentStation = "88896";
    plugin().EnableAutoAnswer = false;
    plugin().EnableReportAgentId = false;
    plugin().ReportIvrDeviceId = "";
    
    plugin().TimeoutThresholdMap = "";//"AS_Idle=10;ReverseSpan=10;Alert=false";
        //状态后处理倒计时阀值设置，第一个参数AS_Idle=10，表示当前是就绪状态下设定就绪了10秒，就开始往外发送阀值提醒事件以及提示窗口，
        //ReverseSpan=10 表示从前一个发送阀值事件开始，就开始倒计时10秒，如果为0，则说明当前不需要倒计时
        //Alert=false 表示当前是否弹出超时提醒的窗口

    plugin().EnableIdleButton       = true;
    plugin().EnableNotreadyButton   = true;
    plugin().EnableWrapupButton     = true;
    plugin().EnableAnswerButton     = true;
    plugin().EnableHangupButton     = true;
    plugin().EnableHoldButton       = true;
    plugin().EnableConsultButton    = true;
    plugin().EnableTransferButton   = true;
    plugin().EnableConferenceButton = true;
    plugin().EnableManageButton     = true;
    plugin().RecSystemType = -1;
    plugin().HangupReasonCodes = "0,空号|1,占线|";
    // 设置是否启用功能按钮
    plugin().EnableFunctionButton01 = false;  //目前此属性用了设定咨询界面上的咨询会议按钮是否可用
    plugin().EnableFunctionButton02 = false;   // 启用功能按钮02 设置在管理界面上置闲/忙和强退按钮是否可见
    plugin().EnableFunctionButton03 = false;  // 启用功能按钮03  在会议ivr的时候调用，设置在会议IVR保持状态的时候收回按钮是否可用
    plugin().EnableFunctionButton04 = true; //控制咨询界面上的咨询和转接按钮是否可用
    plugin().EnableFunctionButton05 = false;
    plugin().EnableFunctionButton06 = false;
    plugin().EnableFunctionButton07 = false;
    plugin().EnableFunctionButton08 = false;
    plugin().EnableFunctionButton09 = false;
    plugin().EnableFunctionButton10 = false;
    // 展现形式
    plugin().DisplayStyle = 0;

    //技能组内容赋值
    plugin().XSPhoneActiveXProperty94 = "2900006|测试技能组1;5000050|测试技能组2;";   
    //配置小休时间策略
    plugin().XSPhoneActiveXProperty93 = "0900|1130;1300|1930;";
    //配置小休超时时间值，以秒为单位
    plugin().XSPhoneActiveXProperty92 = "10";
    //配置签入时的属性
    plugin().XSPhoneActiveXProperty92 = "10";

    plugin().XSPhoneActiveXProperty89 = "Skills=3001:1,3002:1,3003:1;LoginType=voip;ViewCaller=88886666"


    //属性XSPhoneActiveXProperty91用来配置外壳向核心传递参数。格式为A=数据值1;B=数据值2;C=数据值3;.....；等
    plugin().XSPhoneActiveXProperty91 = "IsAgentID=1;";
        
    
    plugin().EnableRecorderAdapter = false; //不使用录音控件  
      
    plugin().AgentId= window.document.getElementById("AgentId").value;
    plugin().AgentPswd=window.document.getElementById("AgentPswd").value;
    plugin().AgentStation=window.document.getElementById("AgentStation").value;
    plugin().actionInit();
} 
function UnInitSoftPhone()
{
	plugin().actionUnInit();
}
function Login()
{	
  
	
    if(plugin().actionLogin())
      {
        plugin().actionCompleteCall();
      };
}
function Logout()
{
	plugin().actionLogout();
}
function Aux()
{
  objSel=window.document.getElementById("Aux_reason");
  plugin().actionSetNotReady(objSel.selectedIndex);
}
function Idle()
{
  plugin().actionSetIdle();
}
function EndAcw()
{
  plugin().actionCompleteCall();
}
function Dialout()
{
  dialOutNum=window.document.getElementById("DialoutNum").value;
  alert(dialOutNum);
  plugin().actionMakeCall(dialOutNum);
}
function Answer()
{
  plugin().actionAnswerCall();
}
function Hangup()
{
  plugin().actionReleaseCall();
}
function Hold()
{
  plugin().actionHoldCall();
}
function Unhold()
{
  plugin().actionRetrieveCall();
}
function Consult()
{
  dialOutNum1=window.document.getElementById("DialoutNum1");
  UserData0=window.document.getElementById("UserData0");
  plugin().actionConsultCall(dialOutNum1,UserData0);
}
function Transfer()
{
  plugin().actionConsultCallXfer();
}
function Conference()
{
  plugin().actionConferenceCall();
}
function ExitConf()
{
  plugin().ConsultCallHangup();
} 
function TransfIVR()
{
  alert("transfIVR  not tested");
}
function UpdateAgent()
{
  alert("updateagent not tested");
}
function UpdateAgent1()
{
  alert("updateagent1  not tested");
}
function load() {     
    addEvent(plugin(), 'test', function(){
        alert("Received a test event from the plugin.");     
    });     
    

    
} 
function pluginLoaded()  { 	    
     InitSoftPhone();  
     addEvent(plugin(),'DidLogin',function(msg){
        alert("DidLogin:"+msg);
    });
addEvent(plugin(),'WillLogin',function(msg){
        alert("WillLogin:"+msg);
    });  
addEvent(plugin(),'StateChanged',function(msg){
        alert("StateChanged:"+msg);
    }); 
}
  	</script>
  </head>
  <body>
  	<div id="doc_wrapper">
    	<!--  begin header -->
	    <div id="header">
	        <div id="headerLeft">
	            <div>
	                <div id="logo">
	                    <a href="http://www.uccfocus.com" target="_blank"><img src="./img/LOGO64-64.png" alt="UCCFocus"></a>
	                </div>
	                <div id="title">
	                    <h2 style="display:inline;">CAAS Softphone Demo</h2>
	                </div>	
	            </div>
	            <div style="clear:both"></div>	
	        </div>	        
	        <div class="title"></div>
	    </div><!-- header -->
	    <br />
  		<div class="div-caassoftphone">
  			<object id="plugin0" type="application/x-caassoftphonecontrol" width="1000" height="45" >
          <param name="onload" value="pluginLoaded" />
    		</object>
  		</div>
  		<br>
  		<SPAN>初始化：</SPAN>
  		<div class="div-f-init">
  			<table style="width:50%;height:*" cellspacing="1">
          <tr>            	
            <td><input id="localSet" type="button" value="初始化-init" onclick="InitSoftPhone()"></td>
            <td><input id="localOpen" type="button" disabled value="反初始化-uninit" onclick="UninitSoftPhone()"></td>            
          </tr>             
        </table>          
  		</div>
  		<br>
  		<SPAN>登录注销：</SPAN>
  		<div class="div-f-loginout">
  			<table style="width:50%;height:*" cellspacing="1">
          <tr bgcolor="#FFFFFF">
            <label>工号：</label>
            <INPUT TYPE="text" id="AgentId" SIZE="15" VALUE="1001">
            <label>密码：</label>
            <INPUT TYPE="password" id="AgentPswd" SIZE="15" VALUE="1001">
            <label>分机：</label>
            <INPUT TYPE="text" id="AgentStation" SIZE="15" VALUE="2001">
          </tr>
          <tr>
  				  <td><input id="Login" type="button" value="登录" onclick="Login()"></td>
            <td><input id="Logout" type="button" value="注销" onclick="Logout()"></td>
          </tr>
        </table> 
      </div> 
      <br>
      <SPAN>座席状态：</SPAN>
      <div class="div-f-agentstat">
        <table style="width:50%;height:*" cellspacing="1">        
          <tr>
            <td><label>置忙原因：</label></td>
            <td>
              <select id="Aux_reason">
                <!-- 0,吃饭|1,会议|2,培训|3,系统故障|4,其他|5,休息|-->
                <option style="width:200px">0.吃饭</option>
                <option style="width:200px">1.会议</option>
                <option style="width:200px">2.培训</option>
                <option style="width:200px">3.系统故障</option>
                <option style="width:200px">4.其他</option>
                <option style="width:200px">5.休息</option>
              </select>
            </td>
            <td><input id="Aux" type="button" value="置忙" onclick="Aux()"></td>
            <td><input id="Ready" type="button" value="置闲" onclick="Idle()"></td>
            <td><input id="EndAcw" type="button" value="结束后处理" onclick="EndAcw()"></td>
          </tr>
        </table>
      </div>
      <br>
      <SPAN>呼叫控制：</SPAN>
      <div class="div-f-callcontrol">
        <table style="width:50%;height:*" cellspacing="1">  			
          <tr>
            <td><label>呼出号码：</label></td>
            <td><INPUT TYPE="text" id="DialoutNum" SIZE="15" VALUE="1002"></td>
          </tr>
          <tr>
            <td><input id="Dialout" type="button" value="拨号" onclick="Dialout()"></td>
            <td><input id="Answer" type="button" value="接听" onclick="Answer()"></td>
            <td><input id="Hangup" type="button" value="挂断" onclick="Hangup()"></td>
            <td><input id="Hold" type="button" value="保持" onclick="Hold()"></td>
            <td><input id="Unhold" type="button" value="取保持" onclick="Unhold()"></td>
          </tr>

        </table>
  		</div>
  		<br>
      <SPAN>呼叫控制(高级)：</SPAN>
      <div class="div-f-callcontrol-ex">
        <table style="width:50%;height:*" cellspacing="1">        
          <tr>
            <td><label>呼叫号码：</label></td>
            <td><INPUT TYPE="text" id="DialoutNum1" SIZE="15" VALUE="1002"></td>
            <td><label>随路数据：</label></td>
            <td><INPUT TYPE="text" id="UserData0" SIZE="25" VALUE="1002"></td>
          </tr>
          <tr>
            <td><input id="Consult" type="button" value="咨询" onclick="Consult()"></td>
            <td><input id="Transfer" type="button" value="转接" onclick="Transfer()"></td>
            <td><input id="Conference" type="button" value="会议" onclick="Conference()"></td>
            <td><input id="ExitConf" type="button" value="结束会议" onclick="ExitConf()"></td>            
          </tr>
        </table>
      </div>
      <br>
      <SPAN>附加控制：</SPAN>
      <div class="div-f-callcontrol-ex">
        <table style="width:50%;height:*" cellspacing="1">        
          <tr>
            <td><label>IVR号码：</label></td>
            <td><INPUT TYPE="text" id="IVRNum" SIZE="10" VALUE="1002"></td>
            <td><label>入口标识：</label></td>
            <td><INPUT TYPE="text" id="IVREnter" SIZE="10" VALUE="1002"></td>
            <td><label size="10">随路数据：</label></td>
            <td><INPUT TYPE="text" id="UserData1" SIZE="25" VALUE="1002"></td>
          </tr>
          <tr>
            <td><input id="Dialout" type="button" value="转接IVR" onclick="TransfIVR()"></td>
            <td><input id="Answer" type="button" value="获取座席列表" onclick="UpdateAgent()"></td>
            <td><input id="Hangup" type="button" value="更新座席列表1" onclick="UpdateAgent1()"></td>                       
          </tr>
        </table>
      </div>
  	</div>  <!--doc wrapper-->
  </body>
